﻿using System;
using System.Collections.Generic;

namespace com.fukefu.spider
{
    class BaiduIp
    {
        List<string> list = new List<string>();
        Random ra = new Random();
        int len;
        string ip = "";

        public BaiduIp()
        {
            list.AddRange(new string[] { "www.baidu.com", "61.135.169.105", "61.135.169.125", "119.75.213.50", "119.75.217.56", "119.75.218.45", "202.108.22.5", "202.108.22.142", "220.181.6.18", "220.181.6.19", "220.181.37.55" });
            this.len = list.Count;
            this.Change();
        }
        //切换
        public void Change()
        {
            string url_new = "";
            do
            {
                url_new = list[ra.Next(len)];
            } while (ip.Equals(url_new));
            ip = url_new;
        }
        //获取ip
        public string GetIp()
        {
            return ip;
        }
    }
}
